{include file="layout/layout" /}

<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <div class="subject">
                <h3>代理管理</h3>
                <h5>网站系统代理索引与管理</h5>
            </div>
        </div>
    </div>
    <!-- 操作说明 -->
    <div id="explanation" class="explanation" style="color: rgb(44, 188, 163); background-color: rgb(237, 251, 248); width: 99%; height: 100%;">
        <div id="checkZoom" class="title"><i class="fa fa-lightbulb-o"></i>
            <h4 title="提示相关设置操作时应注意的要点">操作提示</h4>
            <span title="收起提示" id="explanationZoom" style="display: block;"></span>
        </div>
        <ul>
            <li>代理列表管理, 可以给代理群发站内信、邮件等.</li>
            <li>分销系统可以查看代理上下级信息.</li>
        </ul>
    </div>
    <div class="flexigrid">
        <div class="mDiv">
            <div class="ftitle">
                <h3>代理列表</h3>
                <h5>(共<span id="user_count">{$count}</span>条记录)</h5>
            </div>
            <div title="刷新数据" class="pReload"><a href="{:url('admin/agents/index')}"><i class="fa fa-refresh"></i></a></div>
            <form class="navbar-form form-inline" id="search-form2" onsubmit="return ajax_get_table()" action="{:url('admin/agents/index')}">
                <input type="hidden" name="order_by" value="user_id">
                <input type="hidden" name="sort" value="desc">
                <input type="hidden" name="mobile" value="" id="input-mobile">
                <input type="hidden" name="email" value="" id="input-email">
                <div class="sDiv">
                    <div class="sDiv2">
                        <input type="text" id="search_key" name="searchDetail" value="{$searchDetail}" size="30" class="qsbox" placeholder="手机...">
                       <input type="submit" class="btn" onclick="ajax_get_table('search-form2',1)" value="搜索"id="search_action">
                        <!--<button type="submit" onclick="ajax_get_table('search-form2',1)" id="button-filter search-order" class="btn btn-primary pull-right"><i class="fa fa-search"></i> 筛选</button>-->
                    </div>
                </div>
            </form>
        </div>
        <div class="hDiv">
            <div class="hDivBox">
                <table cellspacing="0" cellpadding="0">
                    <thead>
                    <tr>
                        <th class="sign" axis="col0">
                            <div style="width: 24px;"><i class="ico-check"></i></div>
                        </th>
                        <th align="left" abbr="user_id" axis="col3" class="">
                            <div style="text-align: center; width: 40px;" class="">ID</div>
                        </th>
                        <th align="left" abbr="nickname" axis="col4" class="">
                            <div style="text-align: center; width: 150px;" class="">代理商号</div>
                        </th>
                        <th align="left" abbr="nickname" axis="col4" class="">
                            <div style="text-align: center; width: 150px;" class="">代理账户</div>
                        </th>
                        <th align="left" abbr="nickname" axis="col4" class="">
                            <div style="text-align: center; width: 80px;" class="">代理负责人</div>
                        </th>
                        <th align="center" abbr="level" axis="col5" class="">
                            <div style="text-align: center; width: 150px;" class="">代理区域</div>
                        </th> <th align="center" abbr="level" axis="col5" class="">
                            <div style="text-align: center; width: 50px;" class="">代理商户</div>
                        </th>
                        <th align="center" abbr="total_amount" axis="col6" class="">
                            <div style="text-align: center; width: 50px;" class="">累计收入</div>
                        </th>
                        <th align="center" abbr="email" axis="col6" class="">
                            <div style="text-align: center; width: 150px;" class="">邮件地址</div>
                        </th>

                        <th align="center" abbr="mobile" axis="col6" class="">
                            <div style="text-align: center; width: 80px;" class="">代理电话</div>
                        </th>
                        <th align="center" abbr="user_money" axis="col6" class="">
                            <div style="text-align: center; width: 60px;" class="">账户余额</div>
                        </th>
                        <th align="center" abbr="user_money" axis="col6" class="">
                            <div style="text-align: center; width: 60px;" class="">代理上限</div>
                        </th>
                        <th align="center" abbr="reg_time" axis="col6" class="">
                            <div style="text-align: center; width: 120px;" class="">注册日期</div>
                        </th><th align="center" abbr="reg_time" axis="col6" class="">
                            <div style="text-align: center; width: 120px;" class="">登录时间</div>
                        </th>
                        <th align="center" axis="col6" class="">
                            <div style="text-align: center; width: 140px;" class="">操作</div>
                        </th>
                        <th style="width:100%" axis="col7">
                            <div></div>
                        </th>
                    </tr>
                    </thead>
                </table>
            </div>
        </div>
        <div class="tDiv">
            <div class="tDiv2">
                <div class="fbutton">
                    <a href="{:url('admin/agents/add')}">
                        <div class="add" title="添加代理">
                            <span><i class="fa fa-plus"></i>添加代理</span>
                        </div>
                    </a>
                </div>
                <div class="fbutton">
                    <a href="/index.php/admin/Agents/export_agents">
                        <div class="add" title="添加代理">
                            <span><i class="fa fa-share"></i>导出代理</span>
                        </div>
                    </a>
                </div>

            </div>
            <div style="clear:both"></div>
        </div>
        <div class="bDiv" style="height: auto;" id="ajax_return"><div id="flexigrid" cellpadding="0" cellspacing="0" border="0">
            <table>
                <tbody>
                {volist name="list" id="agents"}
                <tr data-id="2592">
                    <td class="sign">
                        <div style="width: 24px;"><i class="ico-check"></i></div>
                    </td>
                    <td align="left" class="" >
                        <div style="text-align: center; width: 40px;" class="age_agent_manage">{$agents.age_agent_manage}</div>
                    </td>
                    <td align="left" class="" >
                        <div style="text-align: center; width: 150px;">{$agents.agem_number}</div>
                    </td>
                    <td align="left" class="">
                        <div style="text-align: center; width: 150px;">{$agents.age_username}</div>
                    </td>

                    <td align="left" class="">
                        <div style="text-align: center; width: 80px;"><a href="">{$agents.agem_principals}</a></div>
                    </td>
                    <td align="left" class="">
                        <div style="text-align: center; width: 150px;"><input  type="button" class="area2" value="点击查看">
                        </div>
                    </td>
                    <td align="left" class="">
                        <div style="text-align: center; width: 50px;"><a href="{:url('shop/shopList',['agem_id'=>$agents.agem_id])}">查看商户</a></div>
                    </td>
                    <td align="left" class="">
                        <div style="text-align: center; width: 50px;">{$agents.agem_brokerage}</div>
                    </td>
                    <td align="left" class="">
                        <div style="text-align: center; width: 150px;">{$agents.agem_email}</div>
                    </td>

                    <td align="left" class="">
                        <div style="text-align: center; width: 80px;">{$agents.agem_phone}</div>
                    </td>
                    <td align="left" class="">
                        <div style="text-align: center; width: 60px;">{$agents.agem_account}</div>
                    </td>
                    <td align="left" class="">
                        <div style="text-align: center; width: 60px;">{$agents.agem_shop_max}</div>
                    </td>


                    <td align="left" class="">
                        <div style="text-align: center; width: 120px;">{$agents.agem_create_time|date='Y-m-d H:i:s'}</div>
                    </td> <td align="left" class="">
                        <div style="text-align: center; width: 120px;">{$agents.age_login_time|date='Y-m-d H:i:s'}</div>
                    </td>
                    <td align="center" class="handle">
                        <div style="text-align: center; width: 170px; max-width:250px;">
                            <a class="btn blue" href="/index.php/Admin/agents/permitAllocation/agem_id/{$agents.agem_id}"><i class="fa fa-pencil-square-o"></i>分配代理区域</a>
                            <a class="btn blue" href="/index.php/Admin/agents/detail/agem_id/{$agents.agem_id}"><i class="fa fa-pencil-square-o"></i>详情</a>
                            <a class="btn blue" href="/index.php/Admin/agents/update/agem_id/{$agents.agem_id}"><i class="fa fa-pencil-square-o"></i>修改</a>
                            <!--<a class="btn red delete_config2" href="" ><i class="fa fa-trash-o"></i>删除</a>-->
                            <a class="btn red btn-danger" href="javascript:void(0)" data-url="{:url('admin/agents/delete')}" data-id="{$agents.agem_id}" onclick="delfun(this)"><i class="fa fa-trash-o"></i>删除</a>
                        </div>
                    </td>
                    <td align="" class="" style="width: 100%;">
                        <div>&nbsp;</div>
                    </td>
                </tr>
                {/volist}
                </tbody>
            </table>
        </div>
            {$page|raw}
        </div>
        <br>
        <br>
        <br>
    </div>
</div>


<script>
    function delfun(obj){
        layer.confirm('确认删除？', {
                btn: ['确定','取消'] //按钮
            }, function(){
                $.ajax({
                    type : 'get',
                    url : $(obj).attr('data-url'),
                    data : {act:'del',agem_id:$(obj).attr('data-id')},
                    dataType : 'json',
                    success : function(data){
                        layer.closeAll();
                        if(data.status==1){
                            layer.msg('操作成功', {icon: 1});
                            $(obj).parent().parent().parent().remove();
                        }else{
                            layer.msg(data, {icon: 2,time: 2000});
                        }
                        layer.closeAll();
                    }
                })
            }, function(index){
                layer.close(index);
                return false;// 取消
            }
        );
    }
</script>
<script>

    // ajax 抓取页面

    function ajax_get_table(tab,page){
            return true;
    }

</script>
<script>
    $('.area2').click(function () {
        var ids=$(this).parent().parent().parent().index();
        var id=$(".age_agent_manage").eq(ids).html();
        if(!id > 0){
            return;
        }

        var url = 'getAgentRegion';

        $.ajax({
            type : "GET",
            url  : url,
            data:{id: id},
            error: function(request) {
                alert("服务器繁忙, 请联系管理员!");
                return;
            },
            success: function(v) {
                v = '<div style="height: 200px; width: 200px">'+v+' </div>';

                layer.open({
                    type: 1,
                    shade: false,
                    title: false, //不显示标题
                    content: v, //捕获的元素，注意：最好该指定的元素要存放在body最外层，否则可能被其它的相对元素所影响
                    cancel: function(){

                    }
                });
            }
        });



    })

</script>